package com.slipper.common.excel.parse.support;

import org.apache.poi.ss.usermodel.Cell;

import com.slipper.common.excel.ExcelColumn;
import com.slipper.common.excel.ExcelColumnType;
import com.slipper.common.excel.parse.ICellParse;

public abstract class CellParse implements ICellParse {

    /**
     * 解释cell的值
     */
    public String parserCellValue(Cell cell, ExcelColumn column) {
        String value = parserType(cell, column);
        value = parserDicKey(value, column);
        return value;
    }

    /**
     * 解释cell的类型
     */
    public String parserType(Cell cell, ExcelColumn column) {
        if (cell == null || "".equals(cell.toString())) {
            return null;
        }
        String value = cell.toString().trim();
        if (column.type() == ExcelColumnType.TYPE_NO_SUFFIX_EIGHT) {
            value = value.substring(0, value.length() - 3).toUpperCase();
        }
        return value;
    }

    /**
     * 解释map key值
     */
    public String parserDicKey(String value, ExcelColumn column) {
        return value;
    }
}
